package com.aijk.commons.utils;

import com.aijk.base.entity.SmsRequest;
import com.aijk.commons.mq.entity.MqTopicConst;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.aijk.commons.mq.utils.MqUtils;

import java.util.UUID;

/**
 * <p>  </p>
 * User: chendw
 * Date: 2016/9/27 13:32
 */
public class SmsUtils {

    private SmsUtils() {

    }

    /**
     * 提交短信
     *
     * @param request 短信对象
     * @return
     */
    public static SendResult send(SmsRequest request) {
        return MqUtils.sendMessage(MqTopicConst.GROUP_SMS, MqTopicConst.TOPIC_SMS_SEND, "send", UUID.randomUUID().toString(), request);
    }

    /**
     * 提交短信
     *
     * @param mobile 接收手机号码
     * @param text   短信内容
     * @return
     */
    public static SendResult send(String mobile, String text) {
        SmsRequest request = new SmsRequest();
        request.setMobiles(new String[]{mobile});
        request.setText(text);
        return MqUtils.sendMessage(MqTopicConst.GROUP_SMS, MqTopicConst.TOPIC_SMS_SEND, "send", UUID.randomUUID().toString(), request);
    }
}
